package homework;

public class Homework39 {
    public boolean isSameTree(TreeNode p, TreeNode q) {
        if(p==null&&q!=null){
            return false;
        }
        if(p!=null&&q==null){
            return false;
        }
        if(p==q){
            return true;
        }
        return p.val==q.val&&isSameTree(p.right,q.right)&&isSameTree(p.left,q.left);
    }
}
